package com.hl.sfzy.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

import org.springframework.context.annotation.*;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Spring容器
 */
@Configuration
@ComponentScan(basePackages = "com.hl.sfzy", excludeFilters = {
                @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {
                                RestController.class, Controller.class
                }),
                @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {
                                WebMvcConfigurer.class, WebMvcConfigurationSupport.class
                })
})
@PropertySource("classpath:file.properties")
@EnableTransactionManagement
@Import({ MyBatisConfig.class, DataSourceConfig.class, MultipartConfig.class })
public class SpringConfig {

        @Bean
        public ObjectMapper objectMapper() {
                ObjectMapper objectMapper = new ObjectMapper();
                objectMapper.registerModule(new JavaTimeModule());
                return objectMapper;
        }
}
